package com.iot.nev.gateway.connector.mysql;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

public class SaveDataForMysql {
	public static void saveData(String message){
		int a1[] = {3, 5, 1, 5466, 9999, 2645, 6355, 12, 13, 14, 42345, 15, 16};
    	int a2[] = {2, 12, 3, 210, 32345, 24567, 187, 45678, 284955, 2, 227, 54789, 24578, 168, 54678, 192};
    	int a3[] = {7000, 3112, 32132, 22442, 151, 11, 10450, 23, 11223, 52, 52};
    	int a4[] = {16, 100, 3800};
    	int a5[] = {5, 5, 5};
    	int a6[] = {44, 45, 89, 58, 59, 151, 26, 20, 97, 19, 4, 15};
    	int a7[] = {2, 65535, 7, 7, 7, 7};
    	int a8[] = {1 ,1 ,8888, 88, 21, 54, 78};
    	int a9[] = {1, 221, 55871};
    	MysqlConnector mysqlConnector = new MysqlConnector();
        try {
        	 Connection con = mysqlConnector.getConnection();
	         Statement smt = con.createStatement();
	         //要执行的SQL语句
	         String sql = "insert into vehtest(bVehicle_Status1, bCharge_Status1 ,bRunning_Mode1 ,wVehicle_Speed1 ,wTotal_Voltage1 ,wTotal_Current1 ,bSOC1 ,bDCDC_Status1 ,bGear1 ,wResPositive1 ,bAccPedal1 ,bBrkPedal1 ,bMotor_Num2 ,bMotor_NO2 ,bMotor_Status2 ,bMotor_Controller_Temperature2 ,wMotor_Speed2 ,wMotor_Torque2 ,bMotor_Temperature2 ,wMotor_Voltage2 ,wMotor_Current2 ,bMotor_NO22 ,bMotor_Status22 ,bMotor_Controller_Temperature22 ,wMotor_Speed22 ,wMotor_Torque22 ,bMotor_Temperature22 ,wMotor_Voltage22 ,wBattery_Voltage3 ,wBattery_Current3 ,wFuel_Cnsumption_Rate3 ,wTemperature_Probes_Num3 ,wMax_Temperature3 ,bMax_Temperature_Probe_No3 ,wMax_Hydrogen_Concentration3 ,bMax_Hydrogen_Concentration_No3 ,wMax_Hydrogen_Pressure3 ,bMax_Hydrogen_Pressure_No3 ,bHigh_Voltage_DCDC_STT3 ,bEngine_Status4 ,wCrankshaft_Speed4 ,wFuel_Consumption_Rate4 ,bGPS_Status5 ,dLatitude5 ,dLongitude5 ,bBattery_Subsystem_Max_Voltage_No6 ,bBattery_Cell_Max_Voltage_No6 ,wBattery_Cell_Max_Voltage6 ,bBattery_Subsystem_Min_Voltage_No6 ,bBattery_Cell_Min_Voltage_No6 ,wBattery_Cell_Min_Voltage6 ,bBattery_Subsystem_Max_T_No6 ,bProbe_Max_T_No6 ,wProbe_Max_T6 ,bBattery_Subsystem_Min_T_No6 ,bProbe_Min_T_No6 ,wProbe_Min_T6 ,bHighest_Alarm_Level7 ,dGeneral_Alarm_Flag7 ,bBattery_Error_Num7 ,bMotor_Error_Num7 ,bEngine_Error_Num7 ,bOther_Error_Num7 ,bEnergyStorageSubsystemsNum8 ,bEnergyStorageSubsystemsNo8 ,wVoltage8 ,wCurrent8 ,wStart_Cell_Id8 ,bCurrent_Cell_Num8 ,bEnergyStorageSubsystemsNum9 ,bEnergyStorageSubsystemsNo9 ,wTemperature_Probes_Num9,qq) "
	         		+ "values("+a1[0]+","+a1[1]+","+a1[2]+","+a1[3]+","+a1[4]+","+a1[5]+","+a1[6]+","+a1[7]+","+a1[8]+","+a1[9]+","+a1[10]+","+a1[11]+","
	         				+ ""+a2[0]+","+a2[1]+","+a2[2]+","+a2[3]+","+a2[4]+","+a2[5]+","+a2[6]+","+a2[7]+","+a2[8]+","+a2[9]+","+a2[10]+","+a2[11]+","+a2[12]+","+a2[13]+","+a2[14]+","+a2[15]+","
	         				+ ""+a3[0]+","+a3[1]+","+a3[2]+","+a3[3]+","+a3[4]+","+a3[5]+","+a3[6]+","+a3[7]+","+a3[8]+","+a3[9]+","+a3[10]+","
	         				+ ""+a4[0]+","+a4[1]+","+a4[2]+","
	         				+ ""+a5[0]+","+a5[1]+","+a5[2]+","
	         				+ ""+a6[0]+","+a6[1]+","+a6[2]+","+a6[3]+","+a6[4]+","+a6[5]+","+a6[6]+","+a6[7]+","+a6[8]+","+a6[9]+","+a6[10]+","+a6[11]+","
	         				+ ""+a7[0]+","+a7[1]+","+a7[2]+","+a7[3]+","+a7[4]+","+a7[5]+","
	         				+ ""+a8[0]+","+a8[1]+","+a8[2]+","+a8[3]+","+a8[4]+","+a8[5]+","+a8[6]+","
	         				+ ""+a9[0]+","+a9[1]+","+a9[2]+")";
	         //3.ResultSet类，用来存放获取的结果集！！
	         smt.executeUpdate(sql);
        } catch(SQLException e) {
            //数据库连接失败异常处理
            e.printStackTrace();  
           }catch (Exception e) {
            e.printStackTrace();
       }finally {
    	   mysqlConnector.close();
       }
	}
}
